import { GStatic } from "../../../Core/Manager/DataPool";

const { ccclass } = cc._decorator;
@ccclass
export class SHeroData extends GStatic {
    public parse(obj: any): boolean {
        for (let i = 0; i < obj.data.length; i++) {
            let raw = GStatic.addonRaw<SHeroDataRaw>(obj.data[i]);
            this._data.set(raw.id, raw);
        }
        return true;
    }



    public getHeroByType(type: number): SHeroDataRaw[] {
        let arr = [];
        this._data.forEach((v: SHeroDataRaw) => {
            if (v.type === type && v.true === 1) {
                arr.push(v);
            }
        })
        return arr;
    }


    public getHeroTrue(): SHeroDataRaw[] {
        let arr = [];
        this._data.forEach((v: SHeroDataRaw) => {
            if (v.true === 1) {
                arr.push(v);
            }
        })
        return arr;
    }
}